import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";

@Index("idx_apartment_block_id", ["apartmentBlockId"], {})
@Index("idx_apartment_layout_id", ["apartmentLayoutId"], {})
@Index("idx_area", ["area"], {})
@Index("idx_cover_id", ["coverId"], {})
@Index("idx_rent", ["rent"], {})
@Entity("apartment_group", { schema: "cbox" })
export class ApartmentGroup {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("varchar", {
    name: "title",
    nullable: true,
    comment: "房型标题",
    length: 100,
  })
  title: string | null;

  @Column("float", { name: "rent", precision: 12 })
  rent: number;

  @Column("int", { name: "apartment_block_id" })
  apartmentBlockId: number;

  @Column("float", { name: "area", precision: 12 })
  area: number;

  @Column("int", { name: "apartment_layout_id" })
  apartmentLayoutId: number;

  @Column("tinyint", { name: "visible", width: 1 })
  visible: boolean;

  @Column("bigint", { name: "cover_id" })
  coverId: string;

  @Column("varchar", { name: "creator", length: 32 })
  creator: string;

  @Column("mediumtext", { name: "content", nullable: true })
  content: string | null;

  @Column("timestamp", {
    name: "create_time",
    default: () => "CURRENT_TIMESTAMP",
  })
  createTime: Date;

  @Column("timestamp", {
    name: "update_time",
    default: () => "CURRENT_TIMESTAMP",
  })
  updateTime: Date;

  @Column("varchar", {
    name: "approval",
    length: 16,
    default: () => "'pending'",
  })
  approval: string;
}
